Add this function; remove gtk_toolbar_highlight_drop_location() and
authorSoeren Sandmann <sandmann@daimi.au.dk>
Wed, 29 Oct 2003 01:58:38 +0000 (01:58 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Wed, 29 Oct 2003 01:58:38 +0000 (01:58 +0000)
Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

* gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
function; remove gtk_toolbar_highlight_drop_location() and
gtk_toolbar_unhighlight_drop_location().

Also fix bug where the number of overflowed items were miscounted.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktoolbar.c
gtk/gtktoolbar.h
tests/testtoolbar.c

index 4045df270aa3b426e126563f6018c0f6bbaf4be5..7bb4ceb990fd32471604413af28cd72b3f986cea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+       function; remove gtk_toolbar_highlight_drop_location() and
+       gtk_toolbar_unhighlight_drop_location().
+
+       Also fix bug where the number of overflowed items were miscounted.
+
 Tue Oct 28 12:20:16 2003  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
index 4045df270aa3b426e126563f6018c0f6bbaf4be5..7bb4ceb990fd32471604413af28cd72b3f986cea 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+       function; remove gtk_toolbar_highlight_drop_location() and
+       gtk_toolbar_unhighlight_drop_location().
+
+       Also fix bug where the number of overflowed items were miscounted.
+
 Tue Oct 28 12:20:16 2003  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
index 4045df270aa3b426e126563f6018c0f6bbaf4be5..7bb4ceb990fd32471604413af28cd72b3f986cea 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+       function; remove gtk_toolbar_highlight_drop_location() and
+       gtk_toolbar_unhighlight_drop_location().
+
+       Also fix bug where the number of overflowed items were miscounted.
+
 Tue Oct 28 12:20:16 2003  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
index 4045df270aa3b426e126563f6018c0f6bbaf4be5..7bb4ceb990fd32471604413af28cd72b3f986cea 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+       function; remove gtk_toolbar_highlight_drop_location() and
+       gtk_toolbar_unhighlight_drop_location().
+
+       Also fix bug where the number of overflowed items were miscounted.
+
 Tue Oct 28 12:20:16 2003  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
index 4045df270aa3b426e126563f6018c0f6bbaf4be5..7bb4ceb990fd32471604413af28cd72b3f986cea 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+       function; remove gtk_toolbar_highlight_drop_location() and
+       gtk_toolbar_unhighlight_drop_location().
+
+       Also fix bug where the number of overflowed items were miscounted.
+
 Tue Oct 28 12:20:16 2003  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
index 42c318ecd1e54fbe3ff7218e9602b3c67764973e..3536ed01183a0c9d43974b80a3c6045f081d5008 100644 (file)
@@ -1830,24 +1830,26 @@ get_item_requisition (GtkToolbar  *toolbar,
 }
 
 /**
- * gtk_toolbar_highlight_drop_location:
+ * gtk_toolbar_set_drop_highlight_item:
  * @toolbar: a #GtkToolbar
- * @index: the toolbar position to highlight, or -1
- * @tool_item: a #GtkToolbar that isn't part of a widget hierarchy
- *
- * Highlights the position on the toolbar indicated by @index to give
- * an idea of how @toolbar would look if @tool_item was added to it at
- * @index.
+ * @item: a #GtkToolItem, or %NULL to turn of highlighting
+ * @index: a position on @toolbar
  * 
- * After calling this function gtk_toolbar_unhighlight_drop_location() must
- * be called before @tool_item can be added to any widget hierarchy.
+ * Highlights @toolbar to give an idea of what it would look like
+ * if @item was added to @toolbar at position indicated by @index. If @item
+ * is %NULL, highlighting is turned off. In that case @index is ignored.
+ *
+ * The @tool_item passed to this function must not be part of any widget
+ * hierarchy. When an item is set as drop highlight item it can not
+ * added to any widget hierarchy or used as highlight item for another
+ * toolbar.
  * 
  * Since: 2.4
  **/
 void
-gtk_toolbar_highlight_drop_location (GtkToolbar  *toolbar,
-                                    gint         index,
-                                    GtkToolItem *tool_item)
+gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
+                                    GtkToolItem *tool_item,
+                                    gint         index)
 {
   ToolbarContent *content;
   GtkToolbarPrivate *priv;
@@ -1857,31 +1859,54 @@ gtk_toolbar_highlight_drop_location (GtkToolbar  *toolbar,
   GtkRequisition requisition;
 
   g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
-  g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
+  g_return_if_fail (tool_item == NULL || GTK_IS_TOOL_ITEM (tool_item));
 
   priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
 
+  if (!tool_item)
+    {
+      if (priv->in_dnd)
+       {
+         priv->leaving_dnd = TRUE;
+         reset_all_placeholders (toolbar);
+         ensure_idle_handler (toolbar);
+         
+         if (priv->highlight_tool_item)
+           {
+             gtk_widget_unparent (GTK_WIDGET (priv->highlight_tool_item));
+             g_object_unref (priv->highlight_tool_item);
+             priv->highlight_tool_item = NULL;
+           }
+       }
+      
+      return;
+    }
+
   if (tool_item != priv->highlight_tool_item)
     {
       if (priv->highlight_tool_item)
        g_object_unref (priv->highlight_tool_item);
-      
-      gtk_object_sink (GTK_OBJECT (g_object_ref (tool_item)));
+
+      g_object_ref (tool_item);
+      gtk_object_sink (GTK_OBJECT (tool_item));
 
       priv->highlight_tool_item = tool_item;
       
       gtk_widget_set_parent (GTK_WIDGET (priv->highlight_tool_item),
                             GTK_WIDGET (toolbar));
     }
-  
+
   if (!priv->in_dnd)
     {
       priv->n_overflow_items_when_dnd_started = 0;
       for (list = priv->content; list != NULL; list = list->next)
        {
          content = list->data;
-         if (content->is_overflow)
-           priv->n_overflow_items_when_dnd_started++;
+         if (content->is_overflow &&
+             toolbar_item_visible (toolbar, content->item))
+           {
+             priv->n_overflow_items_when_dnd_started++;
+           }
        }
     }
   
@@ -1946,18 +1971,6 @@ gtk_toolbar_highlight_drop_location (GtkToolbar  *toolbar,
 void
 gtk_toolbar_unhighlight_drop_location (GtkToolbar *toolbar)
 {
-  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  
-  priv->leaving_dnd = TRUE;
-  reset_all_placeholders (toolbar);
-  ensure_idle_handler (toolbar);
-
-  if (priv->highlight_tool_item)
-    {
-      gtk_widget_unparent (GTK_WIDGET (priv->highlight_tool_item));
-      g_object_unref (priv->highlight_tool_item);
-      priv->highlight_tool_item = NULL;
-    }
 }
 
 static void
index ec61e8f60951f75d6759e7503e8eb552182360b6..b15ace289ceb5acab0ad6f2ea0d2766b842d3f7f 100644 (file)
@@ -159,11 +159,9 @@ GtkReliefStyle  gtk_toolbar_get_relief_style          (GtkToolbar      *toolbar)
 gint            gtk_toolbar_get_drop_index            (GtkToolbar      *toolbar,
                                                       gint             x,
                                                       gint             y);
-void            gtk_toolbar_highlight_drop_location   (GtkToolbar      *toolbar,
-                                                      gint             index,
-                                                      GtkToolItem     *tool_item);
-void            gtk_toolbar_unhighlight_drop_location (GtkToolbar      *toolbar);
-
+void            gtk_toolbar_set_drop_highlight_item   (GtkToolbar      *toolbar,
+                                                      GtkToolItem     *tool_item,
+                                                      gint             index);
 
 
 /* internal function */
index d56c77677cb8e17f3a454fb32396b033bf0feb78..04ec128a6fdbc69ffb2013e8a2fff726d5748bbb 100644 (file)
@@ -450,12 +450,12 @@ toolbar_drag_motion (GtkToolbar     *toolbar,
       drag_item = gtk_tool_button_new (NULL, "A quite long button");
       gtk_object_sink (GTK_OBJECT (g_object_ref (drag_item)));
     }
-      
+  
   gdk_drag_status (context, GDK_ACTION_MOVE, time);
 
   index = gtk_toolbar_get_drop_index (toolbar, x, y);
   
-  gtk_toolbar_highlight_drop_location (toolbar, index, drag_item);
+  gtk_toolbar_set_drop_highlight_item (toolbar, drag_item, index);
   
   return TRUE;
 }
@@ -472,7 +472,7 @@ toolbar_drag_leave (GtkToolbar     *toolbar,
       drag_item = NULL;
     }
   
-  gtk_toolbar_unhighlight_drop_location (toolbar);
+  gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
 }
 
 gint